package com.hmall.gateway.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

//用户登录过滤器
//此处在请求头中添加一个authorization=2的头信息
@Slf4j
@Order(-1)
@Component
public class loginFilter implements GlobalFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("用户登录过滤器...");

        String uri = exchange.getRequest().getURI().toString();
        log.info("请求路径uri==>{}",uri);
        return chain.filter(exchange);
    }
}
